﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TalentPools.Model;
using TalentPools.DAL;
using System.Data;

namespace TalentPools.BLL
{
   public class Person_LoginManager
   {
       #region 获取分页数据
       /// <summary>
       /// 获取分页数据
       /// </summary>
       /// <param name="pageIndex"></param>
       /// <param name="pageSize"></param>
       /// <param name="where"></param>
       /// <returns></returns>
       public DataSet GetLoginInfoPage(int pageIndex, int pageSize, string where)
       {
           return new Person_LoginService().GetLoginInfoPage(pageIndex, pageSize, where);
       }
       #endregion

       #region 获取记录数
       /// <summary>
       /// 获取记录数
       /// </summary>
       /// <param name="where"></param>
       /// <returns></returns>
       public int GetLoginInfoCount(string where)
       {
           return new Person_LoginService().GetLoginInfoCount(where);
       }
       #endregion

       #region 根据用户名查询数据数量，用来判断是否存在该用户
       public int CheckUsername(string username)
       {
           return new Person_LoginService().CheckUsername(username);
        }
       #endregion

       #region 登录
       /// <summary>
       /// 根据用户名和密码查询用户数量
       /// </summary>
       /// <param name="userName"></param>
       /// <param name="password"></param>
       /// <returns></returns>
       public int UserCountByLoginInfo(string userName, string password,ref string msg)
       {
           int num=new Person_LoginService().UserCountByLoginInfo(userName, password);
           if (num==1)
           {
               msg = new Person_LoginService().GetPersonState(userName);
           }
           return num;
       }
       #endregion

       #region 注册用户
       public bool RegPersonUser(Person_Login person)
       {
           return new Person_LoginService().InsertLoginInfo(person);
       }
#endregion

       #region 修改用户状态
       /// <summary>
       /// 更改用户状态
       /// </summary>
       /// <param name="id"></param>
       /// <param name="state"></param>
       /// <returns></returns>
       public bool UpdateLoginState(int id, bool state)
       {
           return new Person_LoginService().UpdateLoginInfo(id,state);
       }
       #endregion

       #region 删除用户
       /// <summary>
       /// 删除用户
       /// </summary>
       /// <param name="id"></param>
       /// <returns></returns>
       public bool DeletLoginInfo(int id)
       {
           return new Person_LoginService().DeleteLoginInfo(id);
       }
       #endregion

       #region 修改密码
       /// <summary>
       /// 修改密码
       /// </summary>
       /// <param name="username"></param>
       /// <param name="password"></param>
       /// <returns></returns>
       public bool EditPwd(string username, string password)
       {

           return new Person_LoginService().EditPwd(username, password);
       }

       #endregion

       #region 查询密码
       /// <summary>
       /// 查询旧密码
       /// </summary>
       /// <param name="userName"></param>
       /// <param name="pwd"></param>
       /// <returns></returns>
       public bool CheckPwd(string userName, string pwd)
       {
           string oldpwd = new Person_LoginService().CheckPwd(userName);
           if (pwd == oldpwd)
           {
               return true;
           }
           else
           {
               return false;
           }
       }
       #endregion
   }
}
